 ------------------------------------
--SMOD utils script - by Brian Nevec--
 ------------------------------------
------Part of the SmodWeaponsPack-----
 ------------------------------------

smod = { };

smod.Info =
{
	
	Name = "SMOD Weapons Pack",
	Author = "Luafox, Nevec & Foss",
	Version = 1.0,
	Description = "Weapons from SMOD remade for gmod"
	
};

smod.Weapons =
{
	
	"weapon_soy",
	"weapon_stufflauncher",
	"weapon_scissors",
	"weapon_psp",
	"weapon_heavy_pulse",
	"weapon_gcrowbar",
	"weapon_shovel",
	"weapon_msbomb",
	"weapon_bugspawner",
	"weapon_hk_mp5",
	"weapon_banana",
	"weapon_magicstick",
	"weapon_gauss",
	"weapon_alyxgun",
	"weapon_singularity_bomb",
	"weapon_trip_wire",
	"weapon_custom4"
	
};

local raw = ( file.Read( "smod_resource_manifest.txt" ) or "" );
smod.Resources = { };

for filename in ( raw:gmatch( "[^\n]+" ) ) do
	
	filename = filename:gsub( "\\", "/" );
	
	if( file.Exists( "../"..filename ) ) then
		
		resource.AddFile( filename );
		
		table.insert( smod.Resources, filename );
		
	end
	
end

smod.AdminOnly = CreateConVar( "smod_adminonly", "0", FCVAR_ARCHIVE ):GetBool( );

function smod.RestrictPickup( pl, wep )
	
	if( smod.AdminOnly ) then
		
		if( ValidEntity( pl ) && ValidEntity( wep ) ) then
			
			if( table.HasValue( smod.Weapons, wep:GetClass() ) ) then
				
				if( !pl:IsAdmin( ) ) then
					
					return false;
					
				end
				
			end
			
		end
		
	end
	
end
hook.Add( "PlayerCanPickupWeapon", "smod.RestrictPickup", smod.RestrictPickup );

function smod.Think( )
	
	local convar_val = GetConVarNumber( "smod_adminonly" );
	
	if( smod.AdminOnly != convar_val ) then
		
		local text = "SMod weapons are no longer admin only!";
		
		if( convar_val ) then
			
			text = "Smod weapons are admin only!";
			
		end
		
		for _, pl in pairs( player.GetAll( ) ) do
			
			pl:ChatPrint( text );
			
		end
		
		smod.AdminOnly = convar_val;
		
	end
	
end
hook.Add("Think","smod.Think",smod.Think);

function smod.GravGunInteract( pl, ent )
	
	if( ValidEntity( ent ) && ent:GetClass( ) == "smod_scissor" ) then
		
		return false;
		
	end
	
end
hook.Add( "GravGunPunt", "smod.AllowGGInteract.Punt", smod.GravGunInteract );
hook.Add( "GravGunPickupAllowed", "smod.AllowGGInteract.PickUp", smod.GravGunInteract );